#include<bits/stdc++.h>
using namespace std;
#define int long long
int ans=0,n,a[200005],tmp;
vector<int> v1,v2;
void dfs(int now,string col){
    if(now==n){
        tmp=0;
        v1.clear();
        v2.clear();
        for(int i=0;i<now;i++){
            if(col[i]=='r')v1.push_back(a[i]);
            else v2.push_back(a[i]);
        }
        for(int i=1;i<v1.size();i++){
            if(v1[i]==v1[i-1])tmp+=v1[i];
        }
        for(int i=1;i<v2.size();i++){
            if(v2[i]==v2[i-1])tmp+=v2[i];
        }
        ans=max(ans,tmp);
    }
    else{
        dfs(now+1,col+'r');
        dfs(now+1,col+'b');
    }
}
signed main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        ans=0;
        dfs(0,"");
        cout<<ans<<endl;
    }
}
